package com.ruoyi.city.service.impl;

import java.util.List;

import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.city.mapper.HouseCityMapper;
import com.ruoyi.city.domain.HouseCity;
import com.ruoyi.city.service.IHouseCityService;

/**
 * 城市信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-09-10
 */
@Service
public class HouseCityServiceImpl implements IHouseCityService 
{
    @Autowired
    private HouseCityMapper houseCityMapper;

    /**
     * 查询城市信息
     * 
     * @param cityId 城市信息主键
     * @return 城市信息
     */
    @Override
    public HouseCity selectHouseCityByCityId(Integer cityId)
    {
        return houseCityMapper.selectHouseCityByCityId(cityId);
    }

    /**
     * 查询城市信息列表
     * 
     * @param houseCity 城市信息
     * @return 城市信息
     */
    @Override
    public List<HouseCity> selectHouseCityList(HouseCity houseCity)
    {
        return houseCityMapper.selectHouseCityList(houseCity);
    }

    /**
     * 新增城市信息
     * 
     * @param houseCity 城市信息
     * @return 结果
     */
    @Override
    public int insertHouseCity(HouseCity houseCity)
    {
        return houseCityMapper.insertHouseCity(houseCity);
    }

    /**
     * 修改城市信息
     * 
     * @param houseCity 城市信息
     * @return 结果
     */
    @Override
    public int updateHouseCity(HouseCity houseCity)
    {
        return houseCityMapper.updateHouseCity(houseCity);
    }

    /**
     * 批量删除城市信息
     * 
     * @param cityIds 需要删除的城市信息主键
     * @return 结果
     */
    @Override
    public int deleteHouseCityByCityIds(Integer[] cityIds)
    {
        return houseCityMapper.deleteHouseCityByCityIds(cityIds);
    }

    /**
     * 删除城市信息信息
     * 
     * @param cityId 城市信息主键
     * @return 结果
     */
    @Override
    public int deleteHouseCityByCityId(Integer cityId)
    {
        return houseCityMapper.deleteHouseCityByCityId(cityId);
    }

    @Override
    public AjaxResult changStatus(HouseCity houseCity) {
        HouseCity city = houseCityMapper.selectHouseCityByCityId(houseCity.getCityId());
        city.setStatus(houseCity.getStatus());
        houseCityMapper.updateHouseCityById(city.getCityId(),city.getStatus());
        return AjaxResult.success("修改成功");
    }

}
